diffpress5 2.2.1
Loading...
Searching...
No Matches
diffpress5.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2026 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef DIFFPRESS5_H
29#define DIFFPRESS5_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_analog_in.h"
52#include "drv_i2c_master.h"
53
59
64
69
74#define DIFFPRESS5_PRESSURE_PA_MIN 0
75#define DIFFPRESS5_PRESSURE_PA_MAX 10000
76#define DIFFPRESS5_PRESSURE_SENS_PA 0.00045
77#define DIFFPRESS5_ADC_VOUT_MULTIPLIER 1.5
78
83#define DIFFPRESS5_NUM_CONVERSIONS 200
84
89#define DIFFPRESS5_ADC_RESOLUTION 0x0FFF
90#define DIFFPRESS5_VREF_3V3 3.3
91#define DIFFPRESS5_VREF_5V 5.0
92
97#define DIFFPRESS5_TIMEOUT_MS 2000
98
104#define DIFFPRESS5_SET_DEV_ADDR 0x4D
105 // diffpress5_set
107
112
117
122#define DIFFPRESS5_MAP_MIKROBUS( cfg, mikrobus ) \
123 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
124 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
125 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
126 // diffpress5_map // diffpress5
129
140
145typedef struct
146{
147 analog_in_t adc;
148 i2c_master_t i2c;
149
151 float vref;
154
156
161typedef struct
162{
163 pin_name_t an;
164 pin_name_t scl;
165 pin_name_t sda;
166
167 analog_in_resolution_t resolution;
168 float vref;
169
170 uint32_t i2c_speed;
171 uint8_t i2c_address;
172
174
176
187
193
204
220
235
247err_t diffpress5_read_adc_raw ( diffpress5_t *ctx, uint16_t *raw_adc );
248
260err_t diffpress5_read_adc_voltage ( diffpress5_t *ctx, float *voltage );
261
273err_t diffpress5_set_vref ( diffpress5_t *ctx, float vref );
274
286err_t diffpress5_read_vout ( diffpress5_t *ctx, float *vout );
287
300err_t diffpress5_read_vout_avg ( diffpress5_t *ctx, uint16_t num_conv, float *vout_avg );
301
313
325err_t diffpress5_read_pressure ( diffpress5_t *ctx, uint16_t *pressure );
326
327#ifdef __cplusplus
328}
329#endif
330#endif // DIFFPRESS5_H
331 // diffpress5
333
334// ------------------------------------------------------------------------ END
diffpress5_drv_t
Diff Press 5 Click driver selector.
Definition diffpress5.h:135
@ DIFFPRESS5_DRV_SEL_ADC
Definition diffpress5.h:136
@ DIFFPRESS5_DRV_SEL_I2C
Definition diffpress5.h:137
diffpress5_return_value_t
Diff Press 5 Click return value data.
Definition diffpress5.h:182
@ DIFFPRESS5_ERROR
Definition diffpress5.h:184
@ DIFFPRESS5_OK
Definition diffpress5.h:183
void diffpress5_drv_interface_sel(diffpress5_cfg_t *cfg, diffpress5_drv_t drv_sel)
Diff Press 5 driver interface setup function.
err_t diffpress5_read_pressure(diffpress5_t *ctx, uint16_t *pressure)
Diff Press 5 read pressure function.
err_t diffpress5_read_vout_avg(diffpress5_t *ctx, uint16_t num_conv, float *vout_avg)
Diff Press 5 read vout avg function.
err_t diffpress5_calib_offset(diffpress5_t *ctx)
Diff Press 5 calib offset function.
err_t diffpress5_read_adc_voltage(diffpress5_t *ctx, float *voltage)
Diff Press 5 read voltage level function.
err_t diffpress5_read_vout(diffpress5_t *ctx, float *vout)
Diff Press 5 read vout function.
void diffpress5_cfg_setup(diffpress5_cfg_t *cfg)
Diff Press 5 configuration object setup function.
err_t diffpress5_set_vref(diffpress5_t *ctx, float vref)
Diff Press 5 set vref function.
err_t diffpress5_init(diffpress5_t *ctx, diffpress5_cfg_t *cfg)
Diff Press 5 initialization function.
err_t diffpress5_read_adc_raw(diffpress5_t *ctx, uint16_t *raw_adc)
Diff Press 5 read raw ADC value function.
Diff Press 5 Click configuration object.
Definition diffpress5.h:162
analog_in_resolution_t resolution
Definition diffpress5.h:167
float vref
Definition diffpress5.h:168
uint32_t i2c_speed
Definition diffpress5.h:170
pin_name_t scl
Definition diffpress5.h:164
pin_name_t sda
Definition diffpress5.h:165
pin_name_t an
Definition diffpress5.h:163
uint8_t i2c_address
Definition diffpress5.h:171
diffpress5_drv_t drv_sel
Definition diffpress5.h:173
Diff Press 5 Click context object.
Definition diffpress5.h:146
float zero_press_offset
Definition diffpress5.h:152
float vref
Definition diffpress5.h:151
i2c_master_t i2c
Definition diffpress5.h:148
uint8_t slave_address
Definition diffpress5.h:150
analog_in_t adc
Definition diffpress5.h:147
diffpress5_drv_t drv_sel
Definition diffpress5.h:153